<script lang="ts">
	import Vue from "vue";
	export default Vue.extend({
		mpType: "app",
		globalData: {},
		onLaunch() {
			// #ifndef H5 || APP-PLUS
			this.checkVersion();
			// #endif
		},
		onPageNotFound() {
			uni.redirectTo({ url: "/pages/common/notFound" });
		},

		methods: {
			checkVersion() {
				const {
					onCheckForUpdate,
					onUpdateReady,
					onUpdateFailed,
					applyUpdate,
				} = uni.getUpdateManager();

				onCheckForUpdate((res) => {
					/* 请求完新版本信息的回调 */
				});

				onUpdateReady((res) => {
					uni.showModal({
						title: "更新提示",
						content: "新版本已经准备好，是否重启应用？",
						// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
						success: (res) => res.confirm && applyUpdate(),
					});
				});

				onUpdateFailed((res) => {
					// 新的版本下载失败
					uni.showToast({
						title: "新版本下载失败，请稍后再试。",
						icon: "none",
					});
				});
			},
		},
	});
</script>


<style>
	page,
	view,
	picker,
	button,
	label,
	swiper-item,
	scroll-view,
	cover-view,
	navigator,
	radio-group,
	movable-area,
	movable-view,
	checkbox-group {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: transparent;
		background-repeat: no-repeat;
		background-size: cover;
		background-position: center;
	}
	page {
		height: 100%;
	}
	label {
		flex-direction: row;
		align-items: center;
	}

	scroll-view {
		width: auto;
	}

	picker[disabled],
	button[disabled] {
		opacity: 0.5;
	}
</style>